# 使用visitor模式重写 parser


class Visitor(object):
    def visit(self, element):
        pass


class Element(object):
    def accept(self, v):
        v.visit(self)


"""           """


class Block:
    beginRow = 0  # 起始行号
    linecount = 0  # 函数
    keyName = ''


class BlockConfig(Block):
    beginRow = 0
    linecount = 3
    keyName = 'config'


class BlockTestcases(Block):
    pass


class BlockTeststep(Block):
    pass


class BlockBlank(Block):
    pass


class RowVisitor:
    """
    行处理，visitor模式
    """

    def switch_type(self):
        pass

    def visit(self, row):
        methname = 'visit_' + type(row).__name__
        meth = getattr(self, methname, None)
        if meth is None:
            meth = self.generic_visit
        return meth(row)

    def generic_visit(self, node):
        raise RuntimeError('No {} method'.format('visit_' + type(node).__name__))

    def visit_config(self, row):
        pass

    def visit_teststep(self, row):
        pass

    def visit_testcases(self, row):
        pass

    def visit_blankrow(self, row):
        pass


class FieldVisitor:
    """
    字段处理，visitor 模式
    """
    pass


class ExcelVisitor(RowVisitor):
    def scanExcel(self):
        pass
